import { fileURLToPath, URL } from 'node:url'
import { defineConfig,loadEnv  } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import path from 'path' 
// https://vite.dev/config/
export default defineConfig( (env) => {
	return {
		base: './',
		plugins: [
		  vue(),
		  vueDevTools(),
			AutoImport({
				resolvers: [VantResolver()],
			}),
			Components({
				resolvers: [VantResolver()],
			}),
			createSvgIconsPlugin({
				iconDirs: [path.resolve(process.cwd(), 'src/assets/svg')], // svg的文件路径
				symbolId: 'icon-[name]',
				inject: "body-last",
				customDomId: "__svg__icons__dom__"
			})
		],
		envPrefix:["VUE_APP_","VITE_"],
		define: {
			'process.env': loadEnv(env.mode, process.cwd(),["VUE_","VITE_"]),
		},
		resolve: {
		  alias: {
		    '@': fileURLToPath(new URL('./src', import.meta.url))
		  },
		}
		
	}
})
